<script type="text/javascript">
	
	$(function() {
		$("#cmsInstructorSelectList").datagrid(
				{
					title :"优秀导师",
					fit:true,
					fitColumns:true,
					loadMsg:'加载中,请稍候...',
					checkbox:true,
					url:'cmsEntrepreneurshipInfo.do?loadInstructorSelectList&areaId=${areaId!}',
					columns:[[{field : 'id',checkbox : true},
					          {field:'name',width:100,title:'姓名'},
					          {field:'email',width:100,title:'邮箱'},
					          {field:'tel',width:100,title:'联系电话'},
					        ]],					
				}
		);
		

		$("#cmsInstructorUnSelectList").datagrid(
				{
					title :"未选导师",
					fit:true,
					fitColumns:true,
					loadMsg:'加载中,请稍候...',
					url:'cmsEntrepreneurshipInfo.do?loadInstructorUnSelectList&areaId=${areaId!}',
					columns:[[{field : 'id',checkbox : true},
					          {field:'name',width:100,title:'姓名'},
					          {field:'email',width:100,title:'邮箱'},
					          {field:'tel',width:100,title:'联系电话'},
					        ]],
				}
		);
	});
	//未选->已选
	function instructorRightToLeft(){
		var item = $('#cmsInstructorUnSelectList').datagrid("getSelections");
		printLog(item);
		var removeRows = item.slice(0); 
        if (item) {
            for (var i = item.length - 1; i >= 0; i--) {
                var index = $('#cmsInstructorUnSelectList').datagrid('getRowIndex', item[i]);
                $('#cmsInstructorUnSelectList').datagrid('deleteRow', index);
//                 printLog(item.length);
            }
// 			printLog(removeRows);
            for (var j=0;j<removeRows.length;j++) {
            	
            	printLog(JSON.stringify(removeRows[j]));
            	var temp = JSON.stringify(removeRows[j]);
            	$('#cmsInstructorSelectList').datagrid('appendRow',eval(removeRows[j]));
//             	printLog(eval(removeRows[j]));
            }
        }
        showInstructorInfo();
	}
	//已选->未选
	function instructorLeftToRight(){
		var item = $('#cmsInstructorSelectList').datagrid("getSelections");
		printLog(item);
		var removeRows = item.slice(0); 
        if (item) {
            for (var i = item.length - 1; i >= 0; i--) {
                var index = $('#cmsInstructorSelectList').datagrid('getRowIndex', item[i]);
                $('#cmsInstructorSelectList').datagrid('deleteRow', index);
//                 printLog(item.length);
            }
// 			printLog(removeRows);
            for (var j=0;j<removeRows.length;j++) {
            	
            	printLog(JSON.stringify(removeRows[j]));
            	var temp = JSON.stringify(removeRows[j]);
            	$('#cmsInstructorUnSelectList').datagrid('appendRow',eval(removeRows[j]));
            	printLog(eval(removeRows[j]));
            }
        }
        showInstructorInfo();
	}
	
	function showInstructorInfo() {
		 var selectRows = $('#cmsInstructorSelectList').datagrid('getRows');
		 printLog(selectRows);
		 var configInfo = '';
		 if(selectRows.length>0) {
			 for (var k=0;k<selectRows.length;k++) {
				 configInfo += selectRows[k].id+",";
			 }
		 }
		 $('#cmsInstrSelectInfo').val(configInfo);
	}
</script>
<table style="width:100%;">
  <tr>
    <td style="width:45%;height: 515px;padding: 2px 2px;">
		<table id="cmsInstructorSelectList" >    
		</table>
	</td>
    <td style="text-align: center;height: 515px">
    	<div style="padding: 2px 2px;">
    		<input type="button" value=">" style="width: 40px;"
				onclick="instructorLeftToRight()" /><br /> <br /> 
			<input type="button" value="<" style="width: 40px;" onclick="instructorRightToLeft()" />
    	</div>
		
	</td>
    <td style="width:45%;height: 194px;padding: 2px 2px;">
		<table id="cmsInstructorUnSelectList" >    
		</table>
	</td>
  </tr>
</table>